<?php

//error_reporting(0);
//get the q parameter from URL
$task = $_GET['task'];

/*
//find out which feed was selected
if($q=="Google")
  $xml=("http://news.google.com/news?ned=us&topic=h&output=rss");
elseif($q=="MSNBC")
  $xml=("http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml");
elseif($q=="jeth-ro")
  $xml=("http://sijetro.mine.nu/rss.xml"); */
  
$xml = "http://sijetro.mine.nu/RSS/".$task.".php?task=".$task."&sid=".rand(1,100000);

$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
$channel_show = $channel->getElementsByTagName('show')->item(0)->childNodes->item(0)->nodeValue;

//output elements from "<channel>"
//echo "<a href='" . $channel_link . "'>" . $channel_title . "</a><br />";

//get and output "<item>" elements
if($task == "pvpladder5"){
	$x=$xmlDoc->getElementsByTagName('item');
	for ($i=0; $i<$channel_show; $i++){
	  $item_title = $x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
	  $item_link = $x->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
	  echo ($i+1).". <a href='" . $item_link . "' target='_blank'>" . $item_title . "</a><br />";
	}
	
}	
else if($task == "pvpladderbyjob"){
	$y=$xmlDoc->getElementsByTagName('item');
	for ($i=0; $i<$channel_show; $i++){
	  $title = $y->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
	  $link = $y->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
	  $job = $y->item($i)->getElementsByTagName('job')->item(0)->childNodes->item(0)->nodeValue;
	  echo  "<b>".$job."</b> <a href='" . $link . "' target='_blank'>" . $title . "</a><br />";
	}

}
?>